<?PHP
require_once('ConnectionMysql.php');
require_once('AnexosPostagem.php');

class AnexosPostagemDAO
{
    private $connection = NULL;


    /*************************************************************************
    * Name: __construct
    * Description: Construtor da Classe. Inicializar os Atributos.
    * Parameters: 
    * Returns: Nenhum
    * Author: Felipe O. Simões
    * Last Modified: 00/00/00 - Felipe O. Simões
    *************************************************************************/
    public function __construct()
    {
        $this->connection = new ConnectionMysql(); // Cria a Conexão.
    }


    /*************************************************************************
    * Name: 
    * Description: 
    * Parameters: 
    * Returns: 
    * Author: Felipe O. Simões
    * Last Modified: 00/00/00 - Felipe O. Simões
    *************************************************************************/
    public function insert(AnexosPostagem $obj)
    {
        $sql = "INSERT INTO anexospostagem (nome, endereco, isAtivo, idPostagem)
                VALUES ('". $obj->getNome() ."', '". $obj->getEndereco() ."', '". $obj->getIsAtivo() ."', ". $obj->getIdPostagem() .")";
        
        $this->connection->queryConnect($sql);
    }


    /*************************************************************************
    * Name: 
    * Description: 
    * Parameters: 
    * Returns: 
    * Author: Felipe O. Simões
    * Last Modified: 00/00/00 - Felipe O. Simões
    *************************************************************************/
    public function deletePorId($id)
    {
        $sql = "UPDATE anexospostagem SET isAtivo='N' WHERE idAnexosPostagem=". $id;
        $this->connection->queryConnect($sql);
    }
    
    
    /*************************************************************************
    * Name: 
    * Description: 
    * Parameters: 
    * Returns: 
    * Author: Felipe O. Simões
    * Last Modified: 00/00/00 - Felipe O. Simões
    *************************************************************************/
    public function deletePorObj(AnexosPostagem $obj)
    {
        $sql = "UPDATE anexospostagem SET isAtivo='N' WHERE idAnexosPostagem=". $obj->getIdAnexosPostagem();
        $this->connection->queryConnect($sql);
    }


    /*************************************************************************
    * Name: 
    * Description: 
    * Parameters: 
    * Returns: 
    * Author: Felipe O. Simões
    * Last Modified: 00/00/00 - Felipe O. Simões
    *************************************************************************/
    public function update(AnexosPostagem $obj)
    {
        $sql = "UPDATE anexospostagem SET nome='". $obj->getNome() ."', endereco='". $obj->getEndereco() ."' ,isAtivo='". $obj->getIsAtivo() ."', idPostagem=". $obj->getIdPostagem() ." WHERE idAnexosPostagem=". $obj->getIdAnexosPostagem();
        $this->connection->queryConnect($sql);
    }


    /*************************************************************************
    * Name: 
    * Description: 
    * Parameters: 
    * Returns: 
    * Author: Felipe O. Simões
    * Last Modified: 00/00/00 - Felipe O. Simões
    *************************************************************************/
    public function select()
    {
        $sql = "";
        $this->connection->queryConnect($sql);
    }
}
?>